﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Giaiphongmatbang.DataModel;
using Giaiphongmatbang.BLL;

namespace Giaiphongmatbang.UserControl
{
    public partial class childNav : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

            }
        }

        public void BindData(int ParentID)
        {
            FunctionRepository repository = new FunctionRepository();
            string boxtitle = repository.GetByID(ParentID).FunctionName;
            StringBuilder nav = new StringBuilder("<div class='box-title'>");
            nav.AppendLine(boxtitle);
            nav.AppendLine("</div>");
            nav.AppendLine("<ul>");
            IEnumerable<Function> listFunction = new FunctionRepository().GetChildByParentID(ParentID);
            foreach (var item in listFunction)
            {
                nav.AppendLine("<li><a href='" + item.Url + "'>" + item.FunctionName + "</a></li>");
            }
            nav.AppendLine("</ul>");
            ltrChilNav.Text = nav.ToString();
        }
    }
}